package com.firefly.dao.assembler.ums;

import com.firefly.dao.dao.ums.po.RolePo;
import com.firefly.dao.dto.ums.RoleDto;
import com.firefly.dao.vo.ums.RoleVo;
import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.List;

/**
 * @description: 角色数据类型转换
 * @author: lzg(萤火科技 ： 854378082 @ qq.com)
 * @date: 2022/12/5
 **/
@Component
public class RoleAssembler {
    public List<RoleVo> getListVo(List<RolePo> list) {
        List<RoleVo> result = new ArrayList<>();
        list.forEach(item -> {
            RoleVo tmp = new RoleVo();
            tmp.setId(item.getId());
            tmp.setName(item.getName());
            tmp.setStatus(item.getStatus());
            result.add(tmp);
        });
        return result;
    }

    public RoleVo getVo(RolePo detail) {
        RoleVo result = new RoleVo();
        result.setId(detail.getId());
        result.setName(detail.getName());
        result.setStatus(detail.getStatus());
        return result;
    }

    public RolePo getPo(RoleDto detail) {
        RolePo entity = new RolePo();
        entity.setId(detail.getId());
        entity.setName(detail.getName());
        entity.setStatus(detail.getStatus());
        return entity;
    }
}